﻿<phone:PhoneApplicationPage 
    x:Class="MapViewer.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:nbt="clr-namespace:NamedBinaryTag;assembly=NamedBinaryTag"
	xmlns:nbtc="clr-namespace:NamedBinaryTag.Converters;assembly=NamedBinaryTagConverters"
	xmlns:mmc="clr-namespace:Minecraft.Map.Converters;assembly=MapConverters"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">
	<phone:PhoneApplicationPage.Resources>
		<nbt:TagFile x:Key="SourceFile" />
		<nbtc:TagPathValueConverter x:Key="TagValueConverter" />
		<mmc:DimensionConverter x:Key="DimensionConverter" />
		<mmc:MapImageConverter x:Key="MapImageConverter" WidthName="width" HeightName="height" DataName="colors" />
	</phone:PhoneApplicationPage.Resources>

	<!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="MINECRAFT MAP VIEWER" Style="{StaticResource PhoneTextNormalStyle}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
		<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" DataContext="{Binding Source={StaticResource SourceFile}}">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition Height="Auto"/>
				<RowDefinition />
			</Grid.RowDefinitions>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto"/>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="Auto"/>
			</Grid.ColumnDefinitions>
			<TextBlock Text="Fichier" HorizontalAlignment="Left" VerticalAlignment="Top"/>
			<TextBox x:Name="fileName" HorizontalAlignment="Stretch" TextWrapping="Wrap" Margin="0" d:LayoutOverrides="Height" Grid.Column="1"/>
			<Button Content="Go…" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="2"
					Click="Button_Click" Name="goButton" />
			<TextBlock Text="Résolution" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1"/>
			<StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal" Grid.ColumnSpan="2">
				<TextBlock x:Name="width" TextWrapping="Wrap" VerticalAlignment="Center" TextAlignment="Right" HorizontalAlignment="Left"
					Text="{Binding Converter={StaticResource TagValueConverter}, ConverterParameter=data.width}"
					DataContext="{Binding Path=RootTag}"></TextBlock>
				<TextBlock Text="╳" HorizontalAlignment="Center" VerticalAlignment="Center"/>
				<TextBlock x:Name="height" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Center"
					Text="{Binding Converter={StaticResource TagValueConverter}, ConverterParameter=data.height}"
					DataContext="{Binding Path=RootTag}"></TextBlock>
			</StackPanel>
			<TextBlock Text="Centre" Margin="0,0,28.073,0" d:LayoutOverrides="Width, Height" Grid.Row="2"/>
			<StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" Grid.ColumnSpan="2">
				<TextBlock x:Name="centerX" TextWrapping="Wrap" VerticalAlignment="Center" TextAlignment="Right" HorizontalAlignment="Left"
					Text="{Binding Converter={StaticResource TagValueConverter}, ConverterParameter=data.xCenter}"
					DataContext="{Binding Path=RootTag}"></TextBlock>
				<TextBlock Text="╳" HorizontalAlignment="Center" VerticalAlignment="Center"/>
				<TextBlock x:Name="centerZ" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Center"
					Text="{Binding Converter={StaticResource TagValueConverter}, ConverterParameter=data.zCenter}"
					DataContext="{Binding Path=RootTag}"></TextBlock>
			</StackPanel>
			<TextBlock Text="Échelle" Margin="0,0,35.092,0" d:LayoutOverrides="Width, Height" Grid.Row="3"/>
			<StackPanel Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Orientation="Horizontal">
				<TextBlock x:Name="scale" TextWrapping="Wrap" d:LayoutOverrides="Width"
				Text="{Binding ConverterParameter=data.scale, Converter={StaticResource TagValueConverter}}" HorizontalAlignment="Left" VerticalAlignment="Center" DataContext="{Binding Path=RootTag}" />
			</StackPanel>
			<TextBlock Text="Dimension" HorizontalAlignment="Left" d:LayoutOverrides="Height" Grid.Row="4"/>
			<StackPanel Grid.ColumnSpan="2" Grid.Row="4" Grid.Column="1" Orientation="Horizontal">
				<TextBlock x:Name="dimension" TextWrapping="Wrap" VerticalAlignment="Center"
				Text="{Binding ConverterParameter=data.dimension, Converter={StaticResource DimensionConverter}}" HorizontalAlignment="Left" DataContext="{Binding Path=RootTag}" />
			</StackPanel>
			<ScrollViewer Margin="0,0,-3,-1" Grid.Row="5" Grid.ColumnSpan="3">
				<Border
					BorderThickness="1" BorderBrush="{StaticResource PhoneBorderBrush}" HorizontalAlignment="Center" VerticalAlignment="Center">
					<Image
						Source="{Binding ConverterParameter=data, Converter={StaticResource MapImageConverter}}"
						DataContext="{Binding RootTag}" Stretch="None" />
				</Border>
			</ScrollViewer>
		</Grid>
	</Grid>

</phone:PhoneApplicationPage>